<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/reset.css">
    <style>
        ul,
        li {
            list-style: none;
            margin: 0px;
            padding: 0px;
        }

        #big {
            width: 1250px;
            height: 500px;
            margin: 50px auto;
            /* background: pink; */
        }

        .bigLeft {
            width: 500px;
            height: 500px;
            float: left;
            background: #cccccc;
        }


        .bigLeft-top {
            width: 500px;
            height: 400px;
        }

        .bigLeft-top>img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .bigLeft-bottom {
            width: 500px;
            height: 100px;
        }

        .bigLeft-bottom>ul>li {
            width: 100px;
            height: 100px;
            float: left;
        }

        .bigLeft-bottom>ul>li>img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .bigRight {
            width: 700px;
            height: 500px;
            float: right;
            margin-left: 50px;
            /* background: skyblue; */
        }

        .bigRight>h2 {
            font-size: 30px;
            font-weight: 700;
            margin-bottom: 20px;
        }

        .bigRight .price {
            font-size: 15px;

        }

        .price>i {
            font-size: 20px;
            padding-left: 30px;
            color: orange;
        }

        .bigRight>p {
            font-size: 15px;
            margin-top: 15px;
        }

        .bigRight>p>em {
            padding-left: 30px;
            font-size: 15px;
        }

        .bigRight .phonecolor {
            margin-top: 20px;
            width: 700px;
            height: 50px;

        }

        .bigRight .phonecolor>dt {
            float: left;

        }

        .bigRight .phonecolor>dd {
            float: left;
            text-align: center;
            margin-left: 15px;
            line-height: 40px;
            width: 100px;
            height: 40px;
            border: 1px solid #cccccc;
        }

        .bigRight .version {
            margin-top: 20px;
            width: 700px;
            height: 50px;

        }

        .version>dt {
            float: left;
        }

        .version>dd {
            float: left;
            text-align: center;
            margin-left: 15px;
            line-height: 40px;
            width: 100px;
            height: 40px;
            border: 1px solid #cccccc;
        }

        .bigRight .package {
            margin-top: 20px;
            width: 700px;
            height: 50px;

        }

        .package>dt {
            float: left;
        }

        .package>dd {
            float: left;
            margin-left: 15px;
            line-height: 40px;
            text-align: center;
            width: 100px;
            height: 40px;
            border: 1px solid #cccccc;
        }

        .bigRight .number {
            margin-top: 20px;
            width: 700px;
            height: 50px;
            margin-bottom: 20px;
        }

        .number>dt {
            float: left;
            padding-top: 10px;
        }

        .number>dd {
            float: left;
            /* margin-left: 15px; */
            line-height: 40px;
            text-align: center;
            width: 150px;
            height: 40px;
            /* border: 1px solid #cccccc; */
        }

        .number>dd>input {
            width: 40px;
        }

        .number>dd>button {
            width: 20px;
        }

        .bigRight .buy {
            width: 120px;
            height: 50px;
            color: orangered;
            text-align: center;
            margin-left: 200px;
        }

        .bigRight .shoppingCar {
            width: 120px;
            height: 50px;
            color: orangered;
            text-align: center;
            margin-left: 80px;
        }
    </style>
</head>

<body>
    <div id="big">
        <!-- <div class="bigLeft">
            <div class="bigLeft-top">
                <img src="img/ip7.jpg" alt="">
            </div>
            <div class="bigLeft-bottom">
                <ul>
                    <li><img src="img/ip7.jpg" alt=""></li>
                    <li><img src="img/ip7.jpg" alt=""></li>
                    <li><img src="img/ip7.jpg" alt=""></li>
                    <li><img src="img/ip7.jpg" alt=""></li>
                    <li><img src="img/ip7.jpg" alt=""></li>
                </ul>
            </div>
        </div>
        <div class="bigRight">
            <h2>iphone7 plugs</h2>
            <span class="price">价格:<i>¥2300.00-5000.00</i></span>
            <p>配送:<em>广东深圳至广东广州</em></p>
            <dl class="phonecolor">
                <dt>存储容量</dt>
                <dd>64G 移动版</dd>
                <dd>128G 移动版</dd>
                <dd>256G 移动版</dd>
                <dd>512G 三通版</dd>
                <dd>1T 三通版</dd>
            </dl>
            <dl class="version">
                <dt>版本类型</dt>
                <dd>中国大陆</dd>
            </dl>
            <dl class="package">
                <dt>套餐类型</dt>
                <dd>官方标配</dd>
                <dd>套餐一</dd>
            </dl>
            <dl class="number">
                <dt>数量</dt>
                <dd><button>-</button><input type="text"><button>+</button></dd>
                <dd>件（库存99999件）</dd>
            </dl>
            <button class="buy fl">立刻购买</button>
            <button class="shoppingCar fl">加入购物车</button>
        </div> -->
    </div>

    <script>
        var goodlist = [{
            id: '0',
            name: 'iphone7 plugs',
            imgurl: 'img/ip7.jpg',
            price: '5888.00 - 5899.00',
        }, {
            id: '1',
            name: 'Note7',
            imgurl: 'img/note7.jpg',
            price: '998.00 - 3899.00',
        }, {
            id: '2',
            name: '荣耀7',
            imgurl: 'img/honor7.jpg',
            price: '1899.00 - 1999.00',
        }, {
            id: '3',
            name: 'iphone7 plugs',
            imgurl: 'img/ip7.jpg',
            price: '5808.00 - 5999.00',
        }];
        // 获取url的参数
        var p = location.search;

        // substring(start) 当只有一个 参数的时候 ，表示从start索引位置开始截取 最后
        p = p.substring(1) //截取的是?之后的所有字符
        var arr = p.split('=') //['id','111']
        var obj = {}; //把数组转换成对象
        obj[arr[0]] = arr[1]; //{id:111}
        // 拿id的属性值 去数据库匹配
        var res = goodlist.filter(function (item, index) {
            return item.id == obj.id
        })

        var big = document.getElementById('big')
        if (res[0].id == obj.id) {
            big.innerHTML = '<div class="bigLeft"><div class="bigLeft-top"><img src="' + res[0].imgurl +
                '" alt=""></div><div class="bigLeft-bottom"><ul><li><img src="' + res[0].imgurl +
                '" alt=""></li><li><img src="' + res[0].imgurl + '" alt=""></li><li><img src="' + res[0].imgurl +
                '" alt=""></li><li><img src="' + res[0].imgurl + '" alt=""></li><li><img src="' + res[0].imgurl +
                '" alt=""></li></ul></div></div><div class="bigRight"><h2>' + res[0].name +
                '</h2><span class="price">价格:<i>¥' + res[0].price +
                '</i></span><p>配送:<em>广东深圳至广东广州</em></p><dl class="phonecolor"><dt>存储容量</dt><dd>64G 移动版</dd><dd>128G 移动版</dd><dd>256G 移动版</dd><dd>512G 三通版</dd><dd>1T 三通版</dd></dl><dl class="version"><dt>版本类型</dt><dd>中国大陆</dd></dl><dl class="package"><dt>套餐类型</dt><dd>官方标配</dd><dd>套餐一</dd></dl><dl class="number"><dt>数量</dt><dd><button>-</button><input type="text"><button>+</button></dd><dd>件（库存99999件）</dd></dl><button class="buy fl">立刻购买</button><button class="shoppingCar fl">加入购物车</button></div>'
        }
    </script>
</body>

</html>